package com.scorpio.server.base;

import com.alibaba.fastjson.JSONObject;
import com.scorpio.api.ServiceApi;
import com.shooter.utils.StringUtil;

/**
 * 服务器底层基础
 * Created by BLACK on 2017/7/25.
 */
public class BaseServer {
    /**
     * 检测空字符串
     *
     * @param text
     * @return
     */
    protected boolean checkStringNull(String text) {
        if (text == null || text.equals("")) {
            return true;
        }
        return false;
    }

    /**
     * 简单的返回消息构成
     *
     * @param code        返回消息代码
     * @param requestCode 请求码
     * @param msg         返回的消息内容
     * @return
     */
    protected JSONObject getServerMeg(int code, int requestCode, String msg) {
        JSONObject object = new JSONObject();
        object.put(ServiceApi.CODE, code);
        object.put(ServiceApi.REQUEST, requestCode);
        object.put(ServiceApi.MSG, msg);
        return object;
    }
    protected JSONObject getServerMeg(int code, int requestCode, JSONObject json) {
        json.put(ServiceApi.CODE, code);
        json.put(ServiceApi.REQUEST, requestCode);
        return json;
    }
}
